package com.ldy.transactional;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import static org.junit.Assert.*;

public class StudentServiceTest {
    ApplicationContext context;
    StudentService studentService;

    @Before
    public void setUp() throws Exception {
         context = new ClassPathXmlApplicationContext("transactional/app-*.xml");
         studentService = context.getBean(StudentService.class);
    }

    @Test
    public void saveNoCatch() throws Exception {
        studentService.saveNoCatch();
    }

    @Test
    public void save1Catch() throws Exception {
        studentService.saveCatch();
    }

    @Test
    public void save1CatchthrowRuntimeException() throws Exception {
        studentService.saveCatchthrowRuntimeException();
    }

}